package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;

import java.util.Arrays;

/**
 * 用水同步：
 * 每次水龙头出水10秒后上传本次用水量，单位/10ml。
 * 电脑板主动上传无需应答：
 *
 */
public class SyncWaterMessage extends ProtocolMessage {

    /** 用水量单位/10ml */
    private short water;

    public short getWater() {
        return water;
    }

    public void setWater(short water) {
        this.water = water;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeShort(this.water);
    }

    @Override
    public void onDeserialize() {
        this.water = this.byteArray.readShort();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("SyncWaterMessage{");
        sb.append("water=").append(water);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
